package com.mtsmda.jpa.domain.manytomanyBidirectional;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "TEACHERS")
public class Teacher {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_TEACHER")
	private Integer idTeacher;
	private String firstnameTeacher;
	private String lastnameTeacher;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = ClassRoom.class, mappedBy = "teachers")
	private Set<ClassRoom> classRooms = new HashSet<>();

	public Teacher() {
		super();
	}

	public Teacher(String firstnameTeacher, String lastnameTeacher) {
		this();
		setFirstnameTeacher(firstnameTeacher);
		setLastnameTeacher(lastnameTeacher);
	}

	public Integer getIdTeacher() {
		return idTeacher;
	}

	public void setIdTeacher(Integer idTeacher) {
		this.idTeacher = idTeacher;
	}

	public String getFirstnameTeacher() {
		return firstnameTeacher;
	}

	public void setFirstnameTeacher(String firstnameTeacher) {
		this.firstnameTeacher = firstnameTeacher;
	}

	public String getLastnameTeacher() {
		return lastnameTeacher;
	}

	public void setLastnameTeacher(String lastnameTeacher) {
		this.lastnameTeacher = lastnameTeacher;
	}

	public Set<ClassRoom> getClassRooms() {
		return classRooms;
	}

	public void setClassRooms(Set<ClassRoom> classRooms) {
		this.classRooms = classRooms;
	}

}